<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.List, manager.*,book.*, member.*" %>
<%
	boolean reduce;
	String msg=null;

	// リクエスト文字列のエンコードを設定
	request.setCharacterEncoding("UTF-8");

	// パラメータの取得
	Integer crtPage = (Integer)request.getAttribute("page");
	Integer cnt = (Integer)request.getAttribute("cnt");
	msg=(String)request.getAttribute("msg");

	if(cnt==null)
	{
		cnt=0;
	}
	if(msg==null)
	{
		msg = String.format("該当 %d件です", cnt);
	}

	@SuppressWarnings("unchecked")
	List<RentalBean> list = (List<RentalBean>)request.getAttribute("list");
%>
<jsp:include page="/share/layout.jsp">
    <jsp:param name="title" value="未返却者一覧"/>
    <jsp:param name="css" value="manager.css"/>
    <jsp:param name="content">
        <jsp:attribute name="value">

<!-- contents start -->
<% if(list!=null) { %>

<% if(msg != null && !"".equals(msg)) { %>
<div style="font-weight:bold;">
	<%= msg %>
</div>
<% } %>

<form id="all" action="./RentalListServlet">
	<div id="button">
		<input class="button" type="submit" value="前日絞り込み" style="margin-bottom:5px; width:100px;" />
		<input type="hidden" name="checker" value="checked">
	</div>
</form>
<form id="wrig" action="./RentalListServlet">
	<div id="button" >
		<input class="button" type="submit" value="全件表示" style="margin-bottom:5px" />
	</div>
</form>

<br />

<form id="mng_form" action="/Books/member/MailEditServlet">
	<table class="list_table">
		<tr>
			<th id="user_id" colspan="2">メールアドレス</th>
			<th id="member_name">氏名</th>
			<th id="member_ruby">フリガナ</th>
<!-- 			<th id="book_title">タイトル</th> -->
<!-- 			<th id="book_isbn">ISBNコード</th> -->
			<th id="rental_date">貸出日</th>
			<th id="return_date">返却予定日</th>
		</tr>
		<%
		for(int i=0; i<list.size(); i++)
		{
			RentalBean rentals = list.get(i);
			MemberBean members=rentals.getMemberBean();
			BookBean books=rentals.getBookBean();
			boolean mailFlag=rentals.isMailFlag();
			System.out.println(mailFlag);
		%>
		<tr <% if(i%2!=0){ out.print("class=\"color\""); }else if(rentals.isMailFlag()){ out.print("class=\"delete\""); } %>>
			<td align="center"><input type="radio" name="id" value="<%= rentals.getId() %>" /></td>
			<td><%= members.getUserId() %></td>
			<td><%= members.getName() %></td>
			<td><%= members.getRuby() %></td>
<%-- 			<td><%= books.getTitle() %></td> --%>
<%-- 			<td><%= books.getIsbn() %></td> --%>
			<td align="center"><%=rentals.getRentalDate() %></td>
			<td align="center"><%=rentals.getReturnPlanDate()  %></td>
		</tr>
		<%
		}
		%>
	</table>

	<div id="paging_area">
		<% if(crtPage > 1) { %>
			<a href="/Books/member/RentalListServlet?page=<%= crtPage-1 %>">前へ</a>
		<% } %>
		<% for(int i=0, p=1; i<cnt; i+=10, p++) { %>
			<a href="/Books/member/RentalListServlet?page=<%= p %>"><%= p %></a>
		<% } %>
		<% if(crtPage * 10 < cnt) { %>
			<a href="/Books/member/RentalListServlet?page=<%= crtPage+1 %>">次へ</a>
		<% } %>
	</div>

<%}

else { %>
	<div id="msg_area">
	<%= msg %>
</div>
	<h3 align="center">リストがありません</h3>
<%} %>

			<div id="button">
			 	<input type="button" value="戻る" class="button" style="cursor:pointer" onClick="history.back(); return false;">
			    <input class="button" type="submit" name="notReturn" value="メール編集" style="width:90px;" />
			    <input class="button" type="submit" name="return" value="返却" />
			 </div>
</form>
<!-- contents end -->
        </jsp:attribute>
    </jsp:param>
</jsp:include>